feat(desktop): add Agent Usage UI backed by the NIP-AM local archive#2035
Draft
wpfleger96 wants to merge 4 commits into
Draft
feat(desktop): add Agent Usage UI backed by the NIP-AM local archive#2035wpfleger96 wants to merge 4 commits into
wpfleger96 wants to merge 4 commits into
Conversation
wpfleger96
marked this pull request as draft
July 17, 2026 17:10
wpfleger96
force-pushed
the
duncan/agent-usage-archive
branch
from
July 20, 2026 17:45
3bdb2a1 to
2451115
Compare
Adds the Rust backend half of the NIP-AM local agent usage feature (Rev 3 frozen plan): a rebuildable agent_metric_index parsed from archived kind-44200 rows, a pure per-field accounting ladder (agent_usage.rs) computing token/cost deltas with adjacent-cumulative preference and direct-value fallback, and the get_agent_usage_series Tauri command wiring backfill, orphan repair, collection-enabled detection, and A13's hasArchivedEvidence into one series response. commit_archive now indexes kind-44200 rows in the same transaction as the canonical event insert, and upsert_archived_event/gc_orphaned_events return/enforce the new-row and cascade-delete invariants (A5/A6) that persistedAgentMetrics and the index's rebuildability depend on. get_agent_usage_series' SQLite core is split into a plain sync fn so it can be driven directly against an in-memory Connection in tests without a Tauri AppState. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Completes Phase 2 of the NIP-AM local agent usage feature. tauriArchive decodes the backend's persistedAgentMetrics count defensively (missing field -> 0, per A5/M2's backward-compatible wire contract) and exposes an onAgentMetricsChanged notifier, fired only when a subscription mutation touches kind 44200 specifically. ArchiveSyncManager routes both its idle/size-triggered and destroy-time flushes through one sendBatch helper that notifies usage listeners only when the backend reports persistedAgentMetrics > 0 — rejections, duplicate-only batches, and non-metric successes never notify, keeping the refresh signal backend-authoritative. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Surfaces per-agent NIP-AM turn-metric usage (tokens, cost, model breakdown, 7d/30d bucket series) in the desktop app, reading from the Phase 2 get_agent_usage_series archive command: - agent-usage/lib/agentUsage.ts: pure client-side helpers -- bucket boundary construction, bigint-safe token formatting, and the ranked overview-row projection shared by both UI surfaces. - agent-usage/hooks.ts: react-query wrapper around get_agent_usage_series with the app's standard retry:1 default. - agent-usage/ui/AgentUsageSection.tsx: ranked per-agent usage rows on the Agents overview, with a 7d/30d window switch, retry-on-error, and a collection-off banner (with or without retained-data coverage copy) linking to Local Archive settings. - agent-usage/ui/AgentUsageFocusedView.tsx: per-agent drill-down (bucketed series + model breakdown) reached via an overview row or the profile panel's Info-tab usage ingress row; wired into AgentsView, UserProfilePanel, and ProfilePanelContext. - Partial badge on rows whose total is a known lower bound (has_unknown_usage), surfaced via the accounting engine's per-field completeness contract. Extends the Rust archive test suite (agent_usage_tests.rs) to close gaps in the pure accounting engine: the f64 cost ladder had no direct outcome.cost assertions, assign_bucket_index's start-inclusive/ end-exclusive edges were only exercised indirectly, validate_request's chrono finite-range rejection was unexercised, and the A2 ranking tiebreak (pubkey ascending on an exact totalTokens tie) had no test distinguishing it from insertion order. tests/e2e/agent-usage.spec.ts (wired into playwright.config.ts's smoke project) exercises both UI surfaces against a mocked get_agent_usage_series: ranked rows, window switching, click-through to the focused view from both the overview row and the profile panel's ingress row, retry recovery from a query error, the collection-off banner and its settings deep link, and the Partial badge. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96
force-pushed
the
duncan/agent-usage-archive
branch
2 times, most recently
from
July 21, 2026 07:00
4576ca6 to
b213a00
Compare
…chive * origin/main: (25 commits) feat(cli): filter archived instances from --template roster resolution (#2207) chore(release): release Buzz Desktop version 0.4.21 (#2209) fix(desktop): clarify data deletion action (#2208) feat: brand authentication complete page (#2192) fix(buzz-acp,buzz-agent): surface stall duration and fate (#2204) fix(desktop): resolve activity feed showing channel UUID instead of message content (#2201) feat(cli): add agents archive/unarchive/archived subcommands (#2173) chore(acp): strip stale finding-number references from comments (#2202) chore(release): release Buzz Mobile version 0.4.9 (#2200) Simplify first-community onboarding choices (UI only) (#2194) fix(mobile): sanitize Android image uploads (#2188) fix(cli): paginate channel directory queries (#2181) Fix persisted agent defaults display (#2182) [codex] Fix missing release tag detection (#2191) feat(web): authenticate gated community browsing (#2190) fix(timeout): unified turn-timeout fix — cap inheritance, steer renewal, activity-aware requeue, LLM stall surfacing (#2175) fix(desktop): scope draft store per workspace relay (#2179) chore(release): release Buzz Mobile version 0.4.8 (#2187) [codex] create release tags with dedicated App (#2186) fix(desktop): avoid forwarding click event as channel callback (#2174) ... Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96
force-pushed
the
duncan/agent-usage-archive
branch
from
July 21, 2026 08:04
b213a00 to
122b043
Compare
wpfleger96
pushed a commit
that referenced
this pull request
Jul 21, 2026
Member
Author
agents-page-usage-sectionOverview Usage section on Agents page — daily bars showing known (700 tokens), partial (≥500), unknown (—), and empty (0) days, with Partial badge on the agent row. focused-usage-viewPer-agent focused usage subview — totals, Partial badge, daily bars, model breakdown, coverage date range, and partial explanation. invalid-only-windowT1 fix — invalid-only window: empty-state shows "could not be counted" copy instead of the misleading "No locally archived usage" message. io-partial-rowT2 fix — row with null total + incomplete I/O: Partial badge is present next to "in 800 · out 200". model-io-fallbackT2 fix — model breakdown: claude-opus renders "in 600 · out 150 Partial" instead of "No usage reported" when the model total is null but I/O fields are known. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Adds a rolling token/cost usage view for agents, sourced from the local NIP-AM metrics archive. Covers both the Agents overview and a focused per-agent subview in the profile panel.
Backend
get_agent_usage_seriesTauri command (archive/agent_usage.rs): reads the local SQLite archive for a rolling 7d/30d window, returns per-agent/per-model token and cost totals with partial/unknown-field flags when evidence is incomplete.persistedAgentMetricsnotifier through the archive sync path so new metric events are picked up without a full resync.Frontend
AgentUsageSection(features/agent-usage/ui/): ranked agent list inAgentsView, between the unified agents list and teams section. Row click-through opens the profile panel focused on usage.AgentUsageFocusedView: per-agent 7d/30d totals with a by-model breakdown, rendered as a focused profile-panel subview (same pattern as Memories/Diagnostics) rather than a new tab.UserProfilePanel/UserProfilePanelSections/UserProfilePanelTabs: threadedcanViewUsage/onOpenUsage(owner-only, bot profiles only) and added aBarChart3ingress row in the Info tab.Tests
agentUsage.test.mjs: pure-helper unit tests (formatting, partial/unknown-field detection, sorting).tests/e2e/agent-usage.spec.ts: loading → resolved, window switch, both click-through paths into the focused view, error/retry, empty state, collection-off banner (with and without retained-data copy), and the partial-total badge.